void main() {
  //Map是将键和值相关联的对象。键和值都可以是任何类型的对象，key唯一
  //1、创建
  Map<String, String> map1 = {'fisrt': 'dart', 'second': 'java'};
  var map2 = <String, String>{'fisrt': 'dart', 'second': 'java'};
  map2['third'] = 'c++';
  List<String> keys = ['fisrt', 'second'];
  List<String> values = ['dart', 'java'];
  var map3 = Map.fromIterables(keys, values); //{fisrt: dart, second: java}
  print(map3);
  //2、常用方法
  print(map3.length);
  print(map3.isEmpty);
  print(map3.isNotEmpty);
  print(map3.keys);
  print(map3.values);
  print(map3.containsKey("key"));
  print(map3.containsValue("key"));
  String fisrt =
      map3.putIfAbsent('fisrt', () => 'dart'); //如果存在就返回对应value,不存在就添加，并返回value
  print(fisrt);
  print(map3);
  String forth = map3.putIfAbsent('forth', () => '.net');
  print(forth);
  print(map3);
  //3、遍历
  map3.forEach((key, value) {
    print("key:$key, value:${value}");
  });
}
